﻿/*
Jolly Jumpers 
Time Limit:1000MS  Memory Limit:1024K


Description:
A sequence of n > 0 integers is called a jolly jumper
if the absolute values of the difference between successive elements
take on all the values 1 through n-1. For instance, 1 4 2 3 is a jolly jumper,
because the absolutes differences are 3, 2, and 1 respectively.
The definition implies that any sequence of a single integer is a jolly jumper.
You are to write a program to determine whether or not each of a number of sequences
is a jolly jumper.

Input:
Each line of input contains an integer n < 3000 followed by n integers representing the sequence. 
Output:
For each line of input, generate a line of output saying "Jolly" or "Not jolly". 
Sample Input:
4 1 4 2 3
5 1 4 2 -1 6
Sample Output:
Jolly
Not jolly
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
	for (unsigned n; EOF!=scanf("%u", &n) && n; )
	{		
		
		int minusend, subtrahend;		
		scanf("%d", &minusend);	
		if(1==n)
		{	if(1==minusend)
				printf("Jolly\n");
			else
				printf("Not jolly\n");
			continue;
		}
		bool * hashes=(bool*)malloc((n+1)*sizeof(bool));
		if(NULL==hashes)
		{
			exit(-1);
			return EXIT_FAILURE;
		}
		unsigned k=1;
		memset(hashes, false, sizeof((n+1)*sizeof(bool)));
		{
			for(unsigned i=1; i<n; ++i ) 
			{
				scanf("%d", &subtrahend);
				unsigned delta=abs(minusend-subtrahend);
				if(delta>=1 && delta<n && !hashes[delta])
				{
					hashes[delta]=true;	
					++k;
				}
				minusend=subtrahend;
			}
		}
		if(k==n)
			printf("Jolly\n");
		else
			printf("Not jolly\n");
		
		free(hashes);
		hashes=NULL;
	}
	return EXIT_SUCCESS;
}